<!-- 浮动
-->

<!-- 清除浮动
    清除浮动后，后续内容才可正常写

-->






<!-- <!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浮动</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        [id^='div'] {
            width: 100px;
            height: 100px;
            background-color: rebeccapurple;
        }

        #div1 {
            width: 75px;
            height: 75px;
            margin: 10px;
            background-color: lightgreen;
            float: left;

        }

        #div2 {
            background-color: aquamarine;
            float: left;
        }

        #div3 {
            background-color: palegoldenrod;
            float: left;

        }

        #div4 {
            background-color: palevioletred;
            float: right;

        }

        #div5 {
            background-color: lightpink;
            float: right;
        }

        #div6 {
            background-color: yellow;
            float: right;
        }
        .clear{
            clear: both;
        }
        .container{
            height: 100px;
            background-color: yellowgreen;
        }
        .container .left{
            float: left;
            width: 45%;
            height: 100px;
            background-color: red;
        }
        .container .right{
            float: right;
            width: 45%;
            height: 100px;
            background-color: blue;
        }
    </style>
</head>

<body>

    <div id="div1">
        div1
    </div>

    <div id="div2">
        div2
    </div>

    <div id="div3">
        div3
    </div>

    <div id="div4">
        div4
    </div>
    <div id="div5">
        div5
    </div>
    <div id="div6">
        div6
    </div>


    <div class="clear"></div>
    <p>清除浮动，后续内容正常写</p>


    <div class="container">
        <div class="left"></div>
        <div class="right"></div>
    </div>
    <div class="clear"></div>
    <p>清除浮动，后续内容正常写</p>

</body>
</html> -->





















<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>浮动</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        [id^='div'] {
            width: 100px;
            height: 100px;
            background-color: rebeccapurple;
        }

        #div1 {
            width: 75px;
            height: 75px;
            margin: 10px;
            background-color: lightgreen;
            float: left;

        }

        #div2 {
            background-color: aquamarine;
            float: left;
        }

        #div3 {
            background-color: palegoldenrod;
            float: left;

        }

        #div4 {
            background-color: palevioletred;
            float: right;

        }

        #div5 {
            background-color: lightpink;
            float: right;
        }

        #div6 {
            background-color: yellow;
            float: right;
        }
        .clear{
            clear: both;
        }
        .container{
            height: auto;
            margin: 0 auto;
        }
        .container .left{
            float: left;
            width: 30%;
            height: 100px;
            background-color: red;
        }
        .container .middle{
            margin-left: 30px;
            float: left;
            width: 30%;
            height: 100px;
            background-color: yellow;
        }
        .container .right{
            float: right;
            width: 30%;
            height: 100px;
            background-color: blue;
        }
        .container::after{
            content: "";
            display: block;
            clear: both;
        }
    </style>
</head>

<body>

    <div id="div1">
        div1
    </div>

    <div id="div2">
        div2
    </div>

    <div id="div3">
        div3
    </div>

    <div id="div4">
        div4
    </div>
    <div id="div5">
        div5
    </div>
    <div id="div6">
        div6
    </div>


    <div class="clear"></div>
    <p>清除浮动，后续内容正常写</p>


    <div class="container">
        <div class="left"></div>
        <div class="left middle"></div>
        <div class="right"></div>
    </div>

    <p>清除浮动，后续内容正常写</p>

</body>
</html>






